package com.woniuxy.qiantai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.qiantai.entity.Product;
import com.woniuxy.qiantai.entity.Shop;
import com.woniuxy.qiantai.mapper.ProductMapper;
import com.woniuxy.qiantai.mapper.ShopMapper;
import com.woniuxy.qiantai.service.ProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author firstGroup
 * @since 2023-02-22 09:45:58
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Autowired
    ProductMapper productMapper;

    @Override
    public Page<Product> selectShopInfoById(Integer currentPage, Integer pageSize, Integer shopId) {//通过商家Id获取该商家的详细信息
        Page<Product> productPage = new Page<>(currentPage,pageSize);
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        if (shopId != null){
            queryWrapper.eq("shop_id",shopId)
                    .eq("status",1);
        }
        Page<Product> productPageById = productMapper.selectPage(productPage,queryWrapper);
        return productPageById;
    }

}
